/**
 * Created by jihb on 4/21/16.
 */
Ext.define('JYnovel.view.system.MenuView',{
    extend:'Ext.container.Viewport',
    alias:'widget.MenuView',
    border:false,
    layout:'border',
    initComponent:function () {
        Ext.applyIf(this,{
            items:[{
                xtype:'MenuGroupGridView',
                region:'west',
                title:'菜单组',
                border:false,
                split: true,
                flex:1
            },{
                xtype:'MenuGridView',
                region:'center',
                title:'菜单',
                border:false,
                split: true,
                flex:1
            },{
                xtype:'MenuFuncGridView',
                region:'east',
                title:'功能菜单',
                border:false,
                split: true,
                flex:1
            }]
        });
        this.callParent(arguments);
    }
});

/**
 * 菜单组
 */
Ext.define('JYnovel.view.system.MenuGroupGridView',{
    extend:'Ext.grid.Panel',
    alias:'widget.MenuGroupGridView',
    border:false,
    layout:'fit',
    plugins: [{
        ptype: 'rowexpander',
        rowBodyTpl: new Ext.XTemplate(
            '<p><b>简介:</b>{remark}</p>'
        )
    }],
    initComponent:function () {
        var store = Ext.create('JYnovel.store.system.MenuStore');
        Ext.applyIf(this,{
            store:store,
            columns:[{
                text: '名称',
                dataIndex: 'name',
                flex:1
            }],
            dockedItems:[{
                xtype:'toolbar',
                dock:'top',
                items:[{
                    text:'添加',
                    name:'menuGropAddBtn',
                    icon:ctx+'/images/icon/add.png'
                }]
            },{
                xtype: 'pagingtoolbar',
                store: store,
                dock: 'bottom',
                displayInfo: true
            }]
        });
        this.callParent(arguments);
    }
});


/**
 * 菜单
 */
Ext.define('JYnovel.view.system.MenuGridView',{
    extend:'Ext.grid.Panel',
    alias:'widget.MenuGridView',
    border:false,
    layout:'fit',
    plugins: [{
        ptype: 'rowexpander',
        rowBodyTpl : new Ext.XTemplate(
            '<p><b>简介:</b>{remark}</p>'
        )
    }],
    initComponent:function () {
        var store = Ext.create('JYnovel.store.system.MenuStore');
        Ext.applyIf(this,{
            store:store,
            columns:[{
                text: '名称',
                dataIndex: 'name',
                flex:1
            },{
                text:'访问路径',
                dataIndex:'path',
                flex:1
            }],
            dockedItems:[{
                xtype:'toolbar',
                dock:'top',
                items:[{
                    text:'添加',
                    name:'menuAddBtn',
                    icon:ctx+'/images/icon/add.png'
                }]
            },{
                xtype: 'pagingtoolbar',
                store: store,
                dock: 'bottom',
                displayInfo: true
            }]
        });
        this.callParent(arguments);
    }
});


/**
 * 功能菜单
 */
Ext.define('JYnovel.view.system.MenuFuncGridView',{
    extend:'Ext.grid.Panel',
    alias:'widget.MenuFuncGridView',
    border:false,
    layout:'fit',
    plugins: [{
        ptype: 'rowexpander',
        rowBodyTpl : new Ext.XTemplate(
            '<p><b>简介:</b>{remark}</p>',
            '<p><b>菜单id:</b>{menuId}</p>'
        )
    }],
    initComponent:function () {
        var store = Ext.create('JYnovel.store.system.MenuStore');
        Ext.applyIf(this,{
            store:store,
            columns:[{
                text: '名称',
                dataIndex:'name',
                flex:1
            },{
                text:'访问路径',
                dataIndex:'path',
                flex:1
            }],
            dockedItems:[{
                xtype:'toolbar',
                dock:'top',
                items:[{
                    text:'添加',
                    name:'menuFuncAddBtn',
                    icon:ctx+'/images/icon/add.png'
                }]
            },{
                xtype: 'pagingtoolbar',
                store: store,
                dock: 'bottom',
                displayInfo: true
            }]
        });
        this.callParent(arguments);
    }
});

Ext.define('JYnovel.view.system.MenuRightMenu',{
    extend:'Ext.menu.Menu',
    alias:'widget.MenuRightMenu',
    initComponent:function () {
        Ext.applyIf(this,{
            items:[{
                text:'编辑',
                icon:ctx+'/images/icon/bullet_edit.png',
                name:'menuEditMenuItem'
            },{
                text:'删除',
                icon:ctx+'/images/icon/delete.png',
                name:'menuDeleteMenuItem'
            }]
        });
        this.callParent(arguments);
    }
});

